{%extends 'theme/'+GetConfig('theme')+'/layout.html'%}
{% import 'theme/'+GetConfig('theme')+'/_macro.html' as macros %}

{%block content%}
<div class="mdui-container-fluid">
    <div class="nexmoe-item">
        <div class="mdui-row">
            <ul class="mdui-list">
                <li class="mdui-list-item th">
                    <div class="mdui-col-xs-8 mdui-col-sm-5">文件</div>
                    <div class="mdui-col-xs-4 mdui-col-sm-2">修改时间</div>
                    <div class="mdui-col-sm-2 mdui-text-right">文件类型</div>
                    <div class="mdui-col-sm-2 mdui-text-right">大小</div>
                </li>

                {%for data in items%}
                    {%if data['type']=='folder' %}
                    <li class="mdui-list-item mdui-ripple">
                        <a href="{{url_for('front.index',path=data['path'])|replace('//','/')}}">
                            <div class="mdui-col-xs-8 mdui-col-sm-5 mdui-text-truncate">
                                <i class="mdui-icon material-icons">folder_open</i> {{data['name']}}
                            </div>
                            <div class="mdui-col-xs-4 mdui-col-sm-2">{{data['lastModtime']}}</div>
                            <div class="mdui-col-sm-2 mdui-text-right">{{data['type']}}</div>
                            <div class="mdui-col-sm-2 mdui-text-right">{{data['size']}}</div>
                        </a>
                    </li>
                    {%else%}
                        <li class="mdui-list-item file mdui-ripple">
                            <a href="{{url_for('front.index',path=data['path'])|safe|replace('//','/')}}" target="_blank">
                                <div class="mdui-col-xs-8 mdui-col-sm-5 mdui-text-truncate">
                                    <i class="mdui-icon material-icons">{{file_ico(data)}}</i> {{data['name']}}
                                </div>
                                <div class="mdui-col-xs-4 mdui-col-sm-2">{{data['lastModtime']}}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{data['type']}}</div>
                                <div class="mdui-col-sm-2 mdui-text-right">{{data['size']}}</div>
                            </a>
                        </li>
                    {%endif%}
                {%endfor%}

            </ul>
        </div>
    </div>
</div>

<div class="mdui-center">
{% if pagination %}
    {{ macros.pagination_widget(pagination, endpoint,path=path,sortby=sortby,order=order,key_word=key_word) }}
{% endif %}
</div>

<script>
var $$ = mdui.JQ;
$$(function() {
    $$('.file a').each(function() {
        $$(this).on('click', function() {
            layer.open({
              type: 2,
              title: 'PyOne播放窗口',
              shadeClose: true,
              shade: 0.8,
              area: ['100%', '100%'],
              content: $$(this).attr('href')+"?action=share" //iframe的url
            });
            return false;
        });
    });
});

function setCookie(c_name, value, exdays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    document.cookie = c_name + "=" + c_value;
}

var ckname='image_mode'
$('#image_view').change(function(){
   if($(this).attr('checked')){
        setCookie(ckname,1,1);
        window.location.href="{{url_for('front.index',path=path,image_mode=0)}}";
   }else{
        setCookie(ckname,0,1);
        window.location.href="{{url_for('front.index',path=path,image_mode=1)}}";
   }
});
</script>
{%endblock content%}
